#ifndef A58A874A_C164_4A06_A35C_47201C4BADCC
#define A58A874A_C164_4A06_A35C_47201C4BADCC
#include<iostream>
#include<wait.h>
#include<unistd.h>
#include<sys/types.h>
using namespace std;
#define EXIT_CODE 11
int lastcode = 0;


void execute(char* argv[], int argc)
{
    //利用子进程进程替换执行。
    //限制性普通命令：
    cout << endl;
    extern char** environ;
    pid_t id = fork();
    if (id < 0) 
    {
        cerr << "perror" << endl;
        exit(1);
    }
    if (id == 0) //子进程 
    {
        execvp(argv[0], argv);
        //
        exit(EXIT_CODE);
    }
    int status = 0;
    int rid = waitpid(id, &status, 0);
    if (rid == id) 
    {
        lastcode = WEXITSTATUS(status);  //WEXITSTATUS获取退出码的
    }
}


#endif /* A58A874A_C164_4A06_A35C_47201C4BADCC */
